
# generate figure E2

# load packages
library(rio) # load data
library(tidyverse) # data manipulation
library(ggpubr) # combine different plots

# set working directory
setwd("~/replication_files/")

# call R file that estimates models 
source("05_generate_tab1.R")
# note that you need to change the working directory in the source file as well

# re-estimate model 1 with placeboTest = T
fect_placebo1 <- fect(policy_passage ~ article_iv_promotes_governance_lag + imf_program + field_discovery_lag + log_gdp_per_capita_lag + gdp_growth_lag, 
                      data = data_with_dictionary, index = c("iso3c","year"),
                      method = "fe", force = "two-way", seed = 1904,
                      se = TRUE, nboots = 1000, CV = 0, placeboTest = TRUE, placebo.period = c(-3, -1))

plot5 <- plot(fect_placebo1, cex.text = 0.8, stats = c("equiv.p"),
              main = "(a) Treatment: Consultation Promotes Natural Resource Governance", 
              ylab = "Effect on the Probability of Policy Passage") + theme_classic() +
  theme(plot.title = element_text(face="bold"),legend.position="bottom")

# re-estimate model 2 with placeboTest = T
fect_placebo2 <- fect(policy_passage ~ article_iv_mentions_resources_lag + imf_program + field_discovery_lag + log_gdp_per_capita_lag + gdp_growth_lag, 
                      data = data_with_dictionary, index = c("iso3c","year"), 
                      method = "fe", force = "two-way", seed = 1904,
                      se = TRUE, nboots = 1000, CV = 0, placeboTest = TRUE, placebo.period = c(-3, -1))

plot6 <- plot(fect_placebo2, cex.text = 0.8, stats = c("equiv.p"),
              main = "(b) Treatment: Consultation Uses Natural Resource Terms", 
              ylab = "Effect on the Probability of Policy Passage") + theme_classic() +
  theme(plot.title = element_text(face="bold"),legend.position="bottom")

ggarrange(plot5,plot6, ncol = 2) %>%
  ggexport(filename = "figures/figE2.pdf", width = 14, height = 5)

